﻿using BS.Infra;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BS.Write.Api.Controllers
{
    /// <summary>
    /// 养殖记录控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BreedingsController : ControllerBase
    {
        private readonly IMediator _mediator;

        public BreedingsController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 新增养殖信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> CreateBreeding(CreateBreedingCommand command)
        {
            return  await _mediator.Send(command);
            
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult> DelBreeding([FromQuery]DelBreedingCommand command)
        {
            return await _mediator.Send(command);

        }
        /// <summary>
        /// 修改养殖信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult> UpdateBreeding(UpdateBreedingCommand command)
        {
            return await _mediator.Send(command);

        }
    }
}
